package com.lyf.baoxian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lyf.baoxian.R;
import com.lyf.baoxian.bean.CustomerBaoDan;
import com.lyf.baoxian.bean.CustomerInfo;
import com.lyf.baoxian.bean.TestTC;

import java.util.List;

/**
 * Created by 刘亚飞 on 2016/11/30.
 */

public class TaoCanAdapter extends BaseAdapter {
    private List<TestTC> datas;
    private Context context;

    public TaoCanAdapter(Context context) {
        this.context = context;
    }

    public void setDatas(List<TestTC> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_tuijian_taocan, null);
            holder = new ViewHolder();
            holder.iv = (ImageView) view.findViewById(R.id.iv_show);
            holder.title = (TextView) view.findViewById(R.id.tv_title);
            holder.content = (TextView) view.findViewById(R.id.tv_desc);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        TestTC testTC = datas.get(i);
        holder.iv.setImageResource(testTC.getImaId());
        holder.title.setText(testTC.getTitle());
        holder.content.setText(testTC.getContent());

        return view;
    }

    class ViewHolder {
        ImageView iv;
        TextView title;
        TextView content;

    }
}
